#pragma once 
//功能模块
#include <iostream>
#include <string>
#include <fstream>
#include "inc/cppjieba/Jieba.hpp"
#include <boost/algorithm/string.hpp>
namespace ns_util
{
    const char* const DICT_PATH = "./dict/jieba.dict.utf8";
    const char* const HMM_PATH = "./dict/hmm_model.utf8";
    const char* const USER_DICT_PATH = "./dict/user.dict.utf8";
    const char* const IDF_PATH = "./dict/idf.utf8";
    const char* const STOP_WORD_PATH = "./dict/stop_words.utf8";      
    class file_util
    {
    public:
        static bool ReadFile(const std::string& file_path,std::string* out)
        {
            std::ifstream in(file_path,std::ios::in);
            if (!in.is_open()){
                std::cerr << "文件不存在!!" << std::endl;
                return false;
            }
            std::string line;
            while(getline(in,line))
            {
                *out += line; 
            }
            return true;
        }
    };
    class Split
    {   
        public:
        static void SplitLine(std::vector<std::string>*out,const std::string& line,const std::string& sep)
        {
            boost::split(*out, line, boost::is_any_of(sep), boost::token_compress_on);
        }
    };
    class JiebaUtil 
    {
    static cppjieba::Jieba _jieba;
    public:
        static void CutString(const std::string& str,std::vector<std::string>* out)
        {
            _jieba.CutForSearch(str,*out);
        }
    };
    //类内静态成员变量需要到类外初始化
    cppjieba::Jieba JiebaUtil::_jieba(DICT_PATH,HMM_PATH,USER_DICT_PATH,IDF_PATH,STOP_WORD_PATH);
}